package com.one.group.admin.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.one.group.admin.mapper.RepositoryMapper;
import com.one.group.model.dto.RepositoryQueryDto;
import com.one.group.model.entity.Repository;
import com.one.group.model.vo.RepositoryListVo;
import com.one.group.service.RepositoryService;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, Repository> implements RepositoryService {
    @Override
    public List<RepositoryListVo> findRepositoryByQueryDto(RepositoryQueryDto repositoryQueryDto) {
        return this.getMapper().findRepositoryByQueryDto(repositoryQueryDto);
    }

    @Override
    public boolean updateStatus(Long id) {
        Repository repository = this.getMapper().selectOneById(id);
        repository.setStatus(repository.getStatus() == 0 ? 1 : 0);

        return this.getMapper().update(repository)>0;
    }
}
